/**
 * Created by luqidong on 2017/12/15.
 */
import axios from './http';
import {NEWS_URI,MASTER_URI} from '../uitls/ajaxUrl';
/**
 * 获取即时比分
 * @param token
 * @param deviceCode
 * @param issue
 * @returns {*}
 */
export function getImmediatelyScoresR({token, deviceCode = '', issue = ''}) {
    return axios.get(`${MASTER_URI}/ml/football/instant?issue=${issue}`, {
        headers: {
            deviceCode,
            token
        }
    })
}
/**
 * 完场比分
 * @param token
 * @param deviceCode
 * @param issue
 * @returns {*}
 */
export function getOverScoresR({token, deviceCode = '', issue = ''}) {
    return axios.get(`${MASTER_URI}/ml/football/ending?issue=${issue}`, {
        headers: {
            deviceCode,
            token
        }
    })
}
/**
 * 我的比分
 * @param token
 * @param deviceCode
 * @returns {*}
 */
export function getMyScoreR({token, deviceCode = ''}) {
    return axios.get(`${MASTER_URI}/ml/football/follow`, {
        headers: {
            deviceCode,
            token
        }
    })
}
/**
 * 关注 取关 比赛
 * @param token
 * @param issueNo
 * @param isfollow
 * @param deviceCode
 * @returns {*}
 */
export function scoreFollw({token, issueNo, isfollow, deviceCode = ''}) {
    const url = isfollow ? `${MASTER_URI}/ml/football/unfollow` : `${MASTER_URI}/ml/football/follow`;
    return axios.post(url, {lotteryId: '1', issueNo}, {
        headers: {
            token, deviceCode
        }
    })
}

/**
 *比分详情
 * @param issueNo
 * @returns {*}
 */
export function getScoreInfoR(issueNo) {
    return axios.get(`${MASTER_URI}/ml/football/byIssueNo?issueNo=${issueNo}`)
}

//GET /master/ml/plan/byMatch
/**
 * 赛事关联的彩帝推荐单
 * @param token
 * @param issueNo
 * @returns {*}
 */
export function getMatchsByIdR({token, issueNo}) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/plan/byMatch?issueNo=${issueNo}&page=1&pageSize=100`, {
            headers: {
                token
            }
        })
    }
    return axios.get(`${MASTER_URI}/ml/plan/byMatch?issueNo=${issueNo}&page=1&pageSize=100`)
}
/**
 * 赛事分析
 * @param expertId
 * @returns {*}
 */
export function matchsAnalyzeR(expertId) {
    return axios.get(`${MASTER_URI}/ml/expert/leagueAnalyse?expertId=${expertId}`)
}
/**
 * 推荐方案详情
 * @param id
 * @returns {*}
 */
export function recommendmatchdetailsR(id, token) {
    if(token) {
        return axios.get(`${MASTER_URI}/ml/plan/infoByID?planId=${id}`, {
            headers: {
                token
            }
        })
    }
    return axios.get(`${MASTER_URI}/ml/plan/infoByID?planId=${id}`)
}
/**
 * 收藏推荐单
 * @param token
 * @param data
 * @returns {*}
 */
export function collectRecommedR(token, data) {
    return axios.post(`${MASTER_URI}/ml/plan/collect`, data, {
        headers: {
            token
        }
    })
}

/**
 * 取消收藏
 * @param token
 * @param data
 * @returns {*}
 */
export function uncollectRecommedR(token, data) {
    return axios.post(`${MASTER_URI}/ml/plan/collectCancel`, data, {
        headers: {
            token
        }
    })
}
/**
 * 联赛分析
 * @param id
 * @returns {*}
 */
export function getLeagueAnalyseR(id) {
    return axios.get(`${MASTER_URI}/ml/expert/leagueAnalyse?expertId=${id}`);
}
/**
 * 赛事连接
 * @param issueNo
 * @returns {*}
 */
export function getanalyseR(issueNo) {
    return axios.get(`${NEWS_URI}/football/analyse?issueNo=${issueNo}`);
}